import 'package:flutter/material.dart';

import '../../../constants.dart';
import '../../../models/ChatMessage.dart';
import '../../../models/const.dart';
import '../../../models/msg.dart';

class TextMessage extends StatelessWidget {
  const TextMessage({
    Key? key,
    required this.message,
  }) : super(key: key);

  final UIMsg message;

  @override
  Widget build(BuildContext context) {
    var wkMsg = message.wkMsg;
    var isSender = wkMsg.fromUID == UserInfo.uid;

    return Container(
      padding: const EdgeInsets.symmetric(
          horizontal: kDefaultPadding * 0.75, vertical: kDefaultPadding / 2),
      decoration: BoxDecoration(
          color: kPrimaryColor.withOpacity(isSender ? 1 : 0.08),
          borderRadius: BorderRadius.circular(30)),
      child: Text(
        wkMsg.messageContent!.content,
        // softWrap: true,
        overflow: TextOverflow.visible, //超出折行可见
        style: TextStyle(
            color: isSender
                ? Colors.white
                : Theme.of(context).textTheme.bodyLarge?.color,
            height: 1.5),
      ),
    );
  }
}
